// Copyright (C) 2011 YANG Hao (yangh2007@gmail.com). All rights reserved.
//
// This file is part of the (cute)octopus project.
//
// This file may be distributed and/or modified under the terms of the
// GNU General Public License version 2 as published by the Free Software
// Foundation.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// Author(s): YANG Hao


#ifndef OTASKEVENT_H
#define OTASKEVENT_H

#include <QString>
#include "ostd.h"

class OTaskAsync;

class OCTOPUS_EXPORT OEvent : public QEvent
{
public:
	// constructors for task events
	explicit OEvent(const QString& text): QEvent(QEvent::Type(OStd::Event_TaskNotify)), 
		m_text(text), m_taskSender(0){}
	explicit OEvent(double progress): QEvent(QEvent::Type(OStd::Event_TaskNotify)), 
		m_progress(progress), m_taskSender(0){}
	// universal constructor
	OEvent(OStd::EventType t, const QString& text = "", double progress = 0)
		: QEvent(QEvent::Type(t)), 
		m_text(text), m_progress(progress),
		m_taskSender(0){}

	~OEvent(){}

	inline void setSender(OTaskAsync* tsender){m_taskSender = tsender;}

	inline QString text() const {return m_text;}
	inline double progress() const {return m_progress;}
	inline OTaskAsync* sender() const{return m_taskSender;}

private:
	QString m_text;
	double  m_progress;

	OTaskAsync* m_taskSender;
};

class OTaskStartEvent : public OEvent{
public:
	inline OTaskStartEvent() : OEvent(OStd::Event_TaskStarted){}
};

class OTaskStopEvent : public OEvent{
public:
	inline OTaskStopEvent() : OEvent(OStd::Event_TaskStopped){}
};

#endif // OTASKEVENT_H
